package com.quan.system.service.impl;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.quan.common.core.MyBaseServiceImpl;
import com.quan.system.entity.SystemSettings;
import com.quan.system.mapper.SystemSettingsMapper;
import com.quan.system.service.SystemSettingsService;

/**
 * <p>
 * 系统-常量设置 服务实现类
 * </p>
 *
 * @author 杨浩泉
 * @since 2019-07-03
 */
@Service
public class SystemSettingsServiceImpl extends MyBaseServiceImpl<SystemSettingsMapper, SystemSettings> implements SystemSettingsService {


	@Cacheable(value = "SystemSettings", key = "#root.methodName")
	@Override
	public Map<String, Object> getGlobalSettingsMap() {
		Map<String, Object> map = new HashMap<String, Object>() ;
		
		List<SystemSettings> list = super.list();
		for (SystemSettings systemSettings : list) {
			map.put(systemSettings.getSetKey(), systemSettings.getSetValue());
		}
		return map;
	}
	
	@CacheEvict(value = "SystemSettings", allEntries = true)
	@Override
	public boolean save(SystemSettings entity) {
		return super.save(entity);
	}

	@CacheEvict(value = "SystemSettings", allEntries = true)
	@Override
	public boolean updateById(SystemSettings entity) {
		return super.updateById(entity);
	}

	@CacheEvict(value = "SystemSettings", allEntries = true)
	@Override
	public boolean removeById(Serializable id) {
		return super.removeById(id);
	}

	@CacheEvict(value = "SystemSettings", allEntries = true)
	@Override
	public boolean removeByIds(Collection<? extends Serializable> idList) {
		return super.removeByIds(idList);
	}
}
